
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.CureMedicine;
import cn.edu.scau.cmi.hombio.domain.CureTaskMedicine;
import cn.edu.scau.cmi.hombio.domain.Medicine;
import cn.edu.scau.cmi.hombio.domain.MedicineStorageDetail;
import cn.edu.scau.cmi.hombio.domain.MedicineSupplier;
import cn.edu.scau.cmi.hombio.domain.MedicineTakeDetail;
import cn.edu.scau.cmi.hombio.domain.PreventionType;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class MedicineServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected MedicineService service;

	/**
	 * Instantiates a new MedicineServiceTest.
	 *
	 */
	public MedicineServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineSupplier entity
	* 
	 */
	@Test
	public void deleteMedicineMedicineSuppliers() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineMedicineSuppliers 
		Integer medicine_id = 0;
		Integer related_medicinesuppliers_id = 0;
		Medicine response = null;
		response = service.deleteMedicineMedicineSuppliers(medicine_id, related_medicinesuppliers_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineMedicineSuppliers
	}

	/**
	 * Operation Unit Test
	* Load an existing Medicine entity
	* 
	 */
	@Test
	public void loadMedicines() {
		Set<Medicine> response = null;
		response = service.loadMedicines();
		// TODO: JUnit - Add assertions to test outputs of operation: loadMedicines
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineStorageDetail entity
	* 
	 */
	@Test
	public void saveMedicineMedicineStorageDetails() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineMedicineStorageDetails 
		Integer id = 0;
		MedicineStorageDetail related_medicinestoragedetails = new cn.edu.scau.cmi.hombio.domain.MedicineStorageDetail();
		Medicine response = null;
		response = service.saveMedicineMedicineStorageDetails(id, related_medicinestoragedetails);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineMedicineStorageDetails
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findMedicineByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findMedicineByPrimaryKey 
		Integer id_1 = 0;
		Medicine response = null;
		response = service.findMedicineByPrimaryKey(id_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findMedicineByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineStorageDetail entity
	* 
	 */
	@Test
	public void deleteMedicineMedicineStorageDetails() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineMedicineStorageDetails 
		Integer medicine_id_1 = 0;
		Integer related_medicinestoragedetails_id = 0;
		Medicine response = null;
		response = service.deleteMedicineMedicineStorageDetails(medicine_id_1, related_medicinestoragedetails_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineMedicineStorageDetails
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineTakeDetail entity
	* 
	 */
	@Test
	public void deleteMedicineMedicineTakeDetails() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineMedicineTakeDetails 
		Integer medicine_id_2 = 0;
		Integer related_medicinetakedetails_id = 0;
		Medicine response = null;
		response = service.deleteMedicineMedicineTakeDetails(medicine_id_2, related_medicinetakedetails_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineMedicineTakeDetails
	}

	/**
	 * Operation Unit Test
	* Return a count of all Medicine entity
	* 
	 */
	@Test
	public void countMedicines() {
		Integer response = null;
		response = service.countMedicines();
		// TODO: JUnit - Add assertions to test outputs of operation: countMedicines
	}

	/**
	 * Operation Unit Test
	* Delete an existing PreventionType entity
	* 
	 */
	@Test
	public void deleteMedicinePreventionTypesForMedicineId() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicinePreventionTypesForMedicineId 
		Integer medicine_id_3 = 0;
		Integer related_preventiontypesformedicineid_id = 0;
		Medicine response = null;
		response = service.deleteMedicinePreventionTypesForMedicineId(medicine_id_3, related_preventiontypesformedicineid_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicinePreventionTypesForMedicineId
	}

	/**
	 * Operation Unit Test
	* Delete an existing PreventionType entity
	* 
	 */
	@Test
	public void deleteMedicinePreventionTypesForReportMedicineId() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicinePreventionTypesForReportMedicineId 
		Integer medicine_id_4 = 0;
		Integer related_preventiontypesforreportmedicineid_id = 0;
		Medicine response = null;
		response = service.deleteMedicinePreventionTypesForReportMedicineId(medicine_id_4, related_preventiontypesforreportmedicineid_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicinePreventionTypesForReportMedicineId
	}

	/**
	 * Operation Unit Test
	* Save an existing CureTaskMedicine entity
	* 
	 */
	@Test
	public void saveMedicineCureTaskMedicines() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineCureTaskMedicines 
		Integer id_2 = 0;
		CureTaskMedicine related_curetaskmedicines = new cn.edu.scau.cmi.hombio.domain.CureTaskMedicine();
		Medicine response = null;
		response = service.saveMedicineCureTaskMedicines(id_2, related_curetaskmedicines);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineCureTaskMedicines
	}

	/**
	 * Operation Unit Test
	* Save an existing PreventionType entity
	* 
	 */
	@Test
	public void saveMedicinePreventionTypesForReportMedicineId() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicinePreventionTypesForReportMedicineId 
		Integer id_3 = 0;
		PreventionType related_preventiontypesforreportmedicineid = new cn.edu.scau.cmi.hombio.domain.PreventionType();
		Medicine response = null;
		response = service.saveMedicinePreventionTypesForReportMedicineId(id_3, related_preventiontypesforreportmedicineid);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicinePreventionTypesForReportMedicineId
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureTaskMedicine entity
	* 
	 */
	@Test
	public void deleteMedicineCureTaskMedicines() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineCureTaskMedicines 
		Integer medicine_id_5 = 0;
		Integer related_curetaskmedicines_id = 0;
		Medicine response = null;
		response = service.deleteMedicineCureTaskMedicines(medicine_id_5, related_curetaskmedicines_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineCureTaskMedicines
	}

	/**
	 * Operation Unit Test
	* Save an existing Medicine entity
	* 
	 */
	@Test
	public void saveMedicine() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicine 
		Medicine medicine = new cn.edu.scau.cmi.hombio.domain.Medicine();
		service.saveMedicine(medicine);
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineTakeDetail entity
	* 
	 */
	@Test
	public void saveMedicineMedicineTakeDetails() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineMedicineTakeDetails 
		Integer id_4 = 0;
		MedicineTakeDetail related_medicinetakedetails = new cn.edu.scau.cmi.hombio.domain.MedicineTakeDetail();
		Medicine response = null;
		response = service.saveMedicineMedicineTakeDetails(id_4, related_medicinetakedetails);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineMedicineTakeDetails
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineSupplier entity
	* 
	 */
	@Test
	public void saveMedicineMedicineSuppliers() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineMedicineSuppliers 
		Integer id_5 = 0;
		MedicineSupplier related_medicinesuppliers = new cn.edu.scau.cmi.hombio.domain.MedicineSupplier();
		Medicine response = null;
		response = service.saveMedicineMedicineSuppliers(id_5, related_medicinesuppliers);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineMedicineSuppliers
	}

	/**
	 * Operation Unit Test
	* Save an existing CureMedicine entity
	* 
	 */
	@Test
	public void saveMedicineCureMedicines() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineCureMedicines 
		Integer id_6 = 0;
		CureMedicine related_curemedicines = new cn.edu.scau.cmi.hombio.domain.CureMedicine();
		Medicine response = null;
		response = service.saveMedicineCureMedicines(id_6, related_curemedicines);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineCureMedicines
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureMedicine entity
	* 
	 */
	@Test
	public void deleteMedicineCureMedicines() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineCureMedicines 
		Integer medicine_id_6 = 0;
		Integer related_curemedicines_id = 0;
		Medicine response = null;
		response = service.deleteMedicineCureMedicines(medicine_id_6, related_curemedicines_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineCureMedicines
	}

	/**
	 * Operation Unit Test
	* Return all Medicine entity
	* 
	 */
	@Test
	public void findAllMedicines() {
		// TODO: JUnit - Populate test inputs for operation: findAllMedicines 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Medicine> response = null;
		response = service.findAllMedicines(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllMedicines
	}

	/**
	 * Operation Unit Test
	* Save an existing PreventionType entity
	* 
	 */
	@Test
	public void saveMedicinePreventionTypesForMedicineId() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicinePreventionTypesForMedicineId 
		Integer id_7 = 0;
		PreventionType related_preventiontypesformedicineid = new cn.edu.scau.cmi.hombio.domain.PreventionType();
		Medicine response = null;
		response = service.saveMedicinePreventionTypesForMedicineId(id_7, related_preventiontypesformedicineid);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicinePreventionTypesForMedicineId
	}

	/**
	 * Operation Unit Test
	* Delete an existing Medicine entity
	* 
	 */
	@Test
	public void deleteMedicine() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicine 
		Medicine medicine_1 = new cn.edu.scau.cmi.hombio.domain.Medicine();
		service.deleteMedicine(medicine_1);
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
